package com.leave.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.leave.entity.Apply;
import com.leave.util.JdbcUtils;

public class ApproveDao {
	private QueryRunner qr = new QueryRunner(JdbcUtils.getDataSource());

	/**
	 * 通过status查询全部的请假申请
	 * 
	 * @param status
	 * @return
	 * @throws SQLException
	 */
	public List<Apply> show_all_approve(int status) throws SQLException {
		String sql = "select * from leave_apply where status = ?";
		return qr.query(sql, new BeanListHandler<>(Apply.class), status);

	}
	/**
	 * 通过aid是否给予学生审批通过
	 * @param status
	 * @param aid
	 * @throws SQLException
	 */
	public void agree_approve(int status,int aid) throws SQLException {
		String sql = "update leave_apply set status = ? where aid=?";
		qr.update(sql, status,aid);
		
	}
}
